package com.example.lambda;

import java.util.stream.Stream;

/**
 * @Author: 朝花不迟暮
 * @Description: Reduce可以合并流的元素，并生成一个值
 * @Date: 2022/11/4
 */
public class ReduceSample {
    public static void main(String[] args) {
        int sum = Stream.of(1, 2, 3, 4).reduce(0, (a, b) -> a + b);
        System.out.println(sum);
    }
}
